package com.woniuxy.controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.woniuxy.pojo.User;
import com.woniuxy.service.UserService;

@Controller
public class LoginController {

	@Autowired
	private UserService userService;
	
	@RequestMapping("/login")
	public String login(String telephone, String password,HttpSession session) {
		System.out.println(telephone);
		User u = userService.isExist(telephone, password);
		if (u != null) {
			session.setAttribute("login_user", u);
			return "redirect:/index.jsp";
		} else {
			return "redirect:/login.jsp";
		}
	}
}
